package com.powerrich.webmagic;

import com.powerrich.webmagic.PageProcessor.CreditPageProcessor;
import com.powerrich.webmagic.Pipeline.CreditPipeline;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@MapperScan("com.powerrich.mapper")
@RestController
public class SpringBootWebmagicApplication {

    @Autowired
    CreditPageProcessor creditPageProcessor;
    @Autowired
    CreditPipeline creditPipeline;

    @GetMapping("/")
    public String index() {
        new Thread(() -> creditPageProcessor.start(creditPageProcessor, creditPipeline)).start();

        return "爬虫开启";
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringBootWebmagicApplication.class, args);
    }

}
